package com.NeuglsWorkStudio.UI.FormElement.Component
{
	import com.NeuglsWorkStudio.UI.Buttons.TTipButton;
	import com.NeuglsWorkStudio.UI.FormElement.Config.TBitButtonConfig;
	import com.NeuglsWorkStudio.UI.FormElement.Config.TConfig;
	
	import flash.display.DisplayObject;

	public class TBitButton extends TComponent
	{
		private var _FTipButton:TTipButton;
		private var _FTip:String;
		private var _FBaseColor:int;
		private var _FImage:DisplayObject;
		private var _FMouseOver:DisplayObject;
		private var _FMouseDown:DisplayObject;
		private var _FDisable:DisplayObject;
		
		public function TBitButton(AConfig:TConfig)
		{
			super(AConfig);
		}
		
		override protected function Init():void{
			super.Init();
			_FTip=(_FConfig as TBitButtonConfig).Tip;
			_FBaseColor=(_FConfig as TBitButtonConfig).BaseColor;
			_FImage=(_FConfig as TBitButtonConfig).Image;
			_FMouseOver=(_FConfig as TBitButtonConfig).MouseOver;
			_FMouseDown=(_FConfig as TBitButtonConfig).MouseDown;
			_FDisable=(_FConfig as TBitButtonConfig).Disable;
			
			_FTipButton=new TTipButton('',false);
			_FTipButton.Tip=_FTip;
			_FTipButton.TipBackgroundColor=_FBaseColor;
			_FTipButton.AutoAdjustColor=true;
			_FTipButton.Image=_FImage;
			_FTipButton.OnClick=(_FConfig as TBitButtonConfig).OnClick;
			if(_FMouseOver!=null){
				_FTipButton.MouseOverImg=_FMouseOver;
			}
			if(_FMouseDown!=null){
				_FTipButton.MouseDownImg=_FMouseDown;
			}
			if(_FDisable!=null){
				_FTipButton.DisabledImg=_FDisable;
			}
			
			this.addChild(_FTipButton);
		}
	}
}